package com.example.pattern.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体聚合实现
 *
 * @author FM_南风
 * @date 2024/7/6
 */
public class ConcreteAggregate<T> implements Aggregate<T> {
	private List<T> elements = new ArrayList<>();

	public void add(T element) {
		elements.add(element);
	}

	@Override
	public IteratorPatternIterator<T> createIterator() {
		return new ConcreteIterator<>(elements);
	}
}
